package com.zt.ztyh.controller;

import com.zt.ztyh.entity.ZtyhRecording;
import com.zt.ztyh.service.ZtyhRecordingService;
import com.zt.ztyh.vo.UserInfoVo;
import com.zt.ztyh.vo.common.Result;
import com.zt.ztyh.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/ztyh/recording")
public class RecordingController {

    @Autowired
    private ZtyhRecordingService ztyhRecordingService;

    /**
     * 添加流水
     * @return
     */
    @PostMapping("/addRecording")
    public boolean addRecording(@RequestBody ZtyhRecording ztyhRecording) {
        return ztyhRecordingService.addRecording(ztyhRecording);
    }

    /**
     * 所有记录：通过userId拿到 交易发起者和交易接收者都是这个人的所有数据
     * @param userId:用户主键
     * @return:交易记录的集合
     */
    @GetMapping("/getAllRecording")
    public List<ZtyhRecording> getRecording(Long userId,
                                            @RequestParam(required = false) String startTime,
                                            @RequestParam(required = false) String endTime) {
        return ztyhRecordingService.getList(userId,startTime,endTime);
    }


    /**
     * 获取支出流水
     * @param outId:用户主键
     * @param startTime：开始时间
     * @param endTime：结束时间
     * @return:交易记录的集合
     */
    @GetMapping("/getOutRecording")
    public boolean getOutRecording(Long outId, Date startTime, Date endTime) {
//        return ztyhRecordingService;
        return true;
    }

    @GetMapping("/getfindMyjls")
    public Result<ZtyhRecording> findMyjls(Long userId,
                                        @RequestParam(required = false) String startTime,
                                        @RequestParam(required = false) String endTime){
        List<ZtyhRecording> ztyhRecordings= this.ztyhRecordingService.selectZtyhRecordings(userId, startTime, endTime);
        return Result.build(ztyhRecordings, ResultCodeEnum.SUCCESS);
    }
    /**
     * 获取收入流水
     * @param inId:用户主键
     * @param startTime：开始时间
     * @param endTime：结束时间
     * @return:交易记录的集合
     */
    @GetMapping("/getInRecording")
    public boolean getInRecording(Long inId, Date startTime, Date endTime) {
        return true;
    }


    @GetMapping("/listRecording")
    List<ZtyhRecording> getUserListTime(@RequestParam("userId") Long userId,
                                        @RequestParam("openType") int openType
    ){
        return ztyhRecordingService.getUserListTime(userId,openType);
    }
}
